package cn.gov.pbc.gd.credit.web.controller.corp;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.liu.jbase.ResultVo;
import com.liu.jbase.controller.impl.BaseControllerImpl;

import cn.gov.pbc.gd.credit.user.service.corp.ICorpService;
import cn.gov.pbc.gd.credit.vo.corp.CorpVo;
import cn.gov.pbc.gd.credit.vo.corp.ResCorpVo;

@Controller
@RequestMapping("/corp")	
public class CorpController extends BaseControllerImpl<ResCorpVo, CorpVo, ICorpService> {
	
	@Autowired
	private ICorpService corpService;
	
	/**
	 * 
	 * @param id 分行ID，
	 * @param request 根据分行ID，查询当前分行以及其下级分行。
	 * @return
	 */
	@ResponseBody
    @RequestMapping("/list/by/id")
	public ResultVo<List<ResCorpVo>> listById(String id, HttpServletRequest request)  throws Exception{
    	ResultVo<List<ResCorpVo>> res = corpService.listById(id, request);
		return res;
	}
	
	@ResponseBody
    @RequestMapping("tree/list")
	public ResultVo<List<ResCorpVo>> treeList(CorpVo corpVo, HttpServletRequest request)  throws Exception{
		return corpService.treeCropList(corpVo, request);
	}
	
	@RequestMapping("tree/page")
	public String treePage(CorpVo corpVo, Model model, HttpServletRequest request)  throws Exception{
		
		model.addAttribute("result", corpService.treeCropList(corpVo, request));
		
		return "corp/page";
	}
}
